package com.atguigu.order.interceptor;

import feign.RequestInterceptor;
import feign.RequestTemplate;
import org.springframework.cloud.client.loadbalancer.Request;
import org.springframework.stereotype.Component;

import java.util.UUID;

//@Component
public class XTokenRequestInterceptor implements RequestInterceptor {
    /**
     * 拦截器，向请求中添加token
     *
     * @param template
     */
    @Override
    public void apply(RequestTemplate template) {
        System.out.println("拦截器，向请求中添加token-----------------");
        String uuid =UUID.randomUUID().toString();
        System.out.println(uuid);
        template.header("x-token", uuid);
    }
}
